﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeakView.database
{
    class Entities
    {
        public static void AddNetowrkAlarm(string nodeId, string nodeName, bool state)
        {
            NetworkAlarmEntry t = new NetworkAlarmEntry
            {
                Time = DateTime.Now,
                NodeId = nodeId,
                NodeName = nodeName,
                State = state
            };

            using (SqliteDbContext db = new SqliteDbContext())
            {
                db.NetworkAlarmMaster.Add(t);
                db.SaveChanges();
            }

        }

        public static void AddMiscAlarm(string type, string way, string value, string threshold)
        {
            MiscAlarmEntry t = new MiscAlarmEntry
            {
                Time = DateTime.Now,
                Type = type,
                Way = way,
                Value = value,
                Threshold = threshold
            };

            using (SqliteDbContext db = new SqliteDbContext())
            {
                db.MiscAlarmMaster.Add(t);
                db.SaveChanges();
            }

        }

    }

    class NetworkAlarmEntry
    {
        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; }

        /// <summary>
        /// 时间
        /// </summary>
        public DateTime? Time { get; set; }

        /// <summary>
        /// 节点ID
        /// </summary>
        public string NodeId { get; set; }

        /// <summary>
        /// 节点名称
        /// </summary>
        public string NodeName { get; set; }

        /// <summary>
        /// 网络状态，false：离线；true：在线
        /// </summary>
        public bool State { get; set; }

    }

    class MiscAlarmEntry
    {
        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; }

        /// <summary>
        /// 时间
        /// </summary>
        public DateTime? Time { get; set; }

        /// <summary>
        /// 报警类型，输差报警，压差报警
        /// </summary>
        public string Type { get; set; }

        /// <summary>
        /// 报警类型, HIGH, LOW, NOVALUE
        /// </summary>
        public string Way { get; set; }

        /// <summary>
        /// 报警值
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// 阈值
        /// </summary>
        public string Threshold { get; set; }


    }


}
